package com.ruoyi.common.utils.gaode;

import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.constant.GaoDeConstants;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.gaode.domain.GaoDeDto;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.common.utils.spring.SpringUtils;

import java.util.Map;

import static com.ruoyi.common.constant.GaoDeConstants.*;

/**
 * @author zyj
 * @date 2022-08-22 15:42
 */
public class GaoDeUtils {


    /**
     * 通过经纬度获取坐标
     * @return
     */
    public static GaoDeDto getAddress(String latitude,String longitude){
        String key = SpringUtils.getBean(RedisCache.class).getCacheObject(GAO_DE_KEY);
        String stringBuilder = "key=" + key +
                "&location=" + longitude + "," + latitude;
        String s = HttpUtils.sendGet(GAO_DE_URL + GEOCODE_REGEO, stringBuilder);
        return JSON.parseObject(s, GaoDeDto.class);
    }

}
